using UnityEngine;
using System.Collections;

public class Item : MonoBehaviour {

	// Use this for initialization
	void Start () {

	}
	
	void OnTriggerEnter(Collider col){
		string type = GetComponentInChildren<UISprite>().spriteName;
		if(col.tag=="Finish"){
			if(type=="egg"){
				GameController.Instance.Penalty(1);
			}
			StartCoroutine("DeleteObject");
		}
		else if(col.tag=="Player")
		{
			if(type=="egg"){
				GameController.Instance.Score(1);
			}
			else if(type == "shit")
			{
				GameController.Instance.Penalty(1);	
			}
			StartCoroutine("DeleteObject");
		}
	}
	
	IEnumerator DeleteObject(){
		while(true){
			yield return new WaitForEndOfFrame();
			GameObject.Destroy(this.gameObject);
		}
	}
	
	void ClearScene(){
		GameObject.Destroy(this.gameObject);
	}
	
}

public enum ItemType{
	egg,
	shit
}